<?php

namespace app\admin\service\statistics\traits;

use app\admin\service\statistics\filters\GroupFilter;

/**
 * Trait FilterGroupTrait
 * @package app\admin\service\statistics\traits
 */
trait FilterGroupTrait
{

    /**
     * 实现小组筛选
     * @param \think\db\Query $query
     * @param GroupFilter $filter
     * @return void
     */
    protected function filterByGroupFilter($query, GroupFilter $filter): void
    {
        $groups = $filter->getGroups();

        if (!empty($groups)) {

            $query->whereIn('promotionGroupId', $groups);
        }
    }

}